package fr.ece.ing4.si.multithread;

import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

import fr.ece.ing4.si.singlethread.MonteCarlo;
import fr.ece.ing4.si.view.MainView;

public class ConcurerentMonteCarlo {
	
	private static ArrayList<MonteCarlo> data;
	
	/**
	 * Main of MonteCarlo Concurrent Simulation
	 * @param args
	 * @throws IOException
	 * @throws InterruptedException
	 * @throws ExecutionException
	 */
	
public static void main(final String[] args) throws IOException, InterruptedException, ExecutionException {
	
		data = MonteCarlo.ReadData();
		
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
			try {
				new MainView(data, "MultiThread");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			}
		});
	}
/**
 * 
 * @param m Montecarlo object to compute the Option
 * @return The result of the computation
 * @throws InterruptedException
 * @throws ExecutionException
 */
	public static double compute(MonteCarlo m) throws InterruptedException, ExecutionException{
		return m.ConcurrentMonteCarloStandardOption();
	}
}
